﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Data.SqlClient;
using Server_NhaSach.DataTransferObject;
using Server_NhaSach.DataAccess.LogicLayer;


namespace Server_NhaSach.BusinessLayer
{
    [Serializable]
    public class TaiKhoanOnlineBlo
    {
        #region "Khai báo các biến"
        private TaiKhoanOnlineDAO da;
        private TaiKhoanOnlineDTO _TKOL;
        private string _error;
        #endregion
        #region "Khai báo các thuộc tính"
        public string Error
        {
            get { return _error; }
        }
        public TaiKhoanOnlineDTO TKOL
        {
            get { return _TKOL; }
            set { _TKOL = value; }
        }
        #endregion
        #region "Khai báo các Method"
        public TaiKhoanOnlineBlo()
        {            
            da = new TaiKhoanOnlineDAO();
        }
        public bool InsertTKOL(string MaTKOL,string TenDangNhap,string MatKhau,string DiaChi,string SDT,string Email,DateTime NgayDangKy)
        {
            _TKOL = new TaiKhoanOnlineDTO(MaTKOL, TenDangNhap, MatKhau, DiaChi, SDT, Email, NgayDangKy);
            if (!da.InsertTKOL(TKOL))
            {
                _error = da.Error;
                return false;
            }
            return true;
        }
        public bool UpdateTKOL(string MaTKOL, string TenDangNhap, string MatKhau, string DiaChi, string SDT, string Email, DateTime NgayDangKy)
        {
            _TKOL = new TaiKhoanOnlineDTO(MaTKOL, TenDangNhap, MatKhau, DiaChi, SDT, Email, NgayDangKy);
            if (!da.UpdateTKOL(TKOL))
            {
                _error = da.Error;
                return false;
            }
            return true;
        }
        public bool DeleteTKOL(string MaTKOL)
        {
            if (!da.DeleteTKOL(MaTKOL))
            {
                _error = da.Error;
                return false;
            }
            return true;
        }
        public DataSet LayDS_TaiKhoanOnline()
        {
            DataSet ds = new DataSet();
            ds = da.LayDS_TaiKhoanOnline();
            return ds;
        }
        #endregion 
    }
}